import {SET_SIGN_TYPE} from 'src/store/mutationTypes'
import signTypes from 'src/data/signTypes'
import {persistent} from 'src/store/plugin/storage'

export default {
  state: {
    @persistent(SET_SIGN_TYPE)
    signType: null
  },
  getters: {
    signType (state) {
      return state.signType || signTypes[0].code
    },
    signByVerifyCode (state, getters) {
      return getters.signType === 'verifyCode'
    },
    signByPassword (state, getters) {
      return getters.signType === 'password'
    }
  },
  mutations: {
    [SET_SIGN_TYPE] (state, {signType}) {
      state.signType = signType
    }
  }
}
